<template>
    <noticeBar :data="alarmData" v-if="showNotice" :message="message"></noticeBar>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import noticeBar from './components/noticeBar.vue'
import apis from '@/api/apis'
const alarmData = ref([
    {
        type: 'danger',
        content: '警告来自xxx区域，发生xxx异常，请派人前往查看',
    },
    {
        type: 'warning',
        content: '警告来自xxx区域，发生xxx异常，请派人前往查看',
    },
    {
        type: 'success',
        content: '警告来自xxx区域，发生xxx异常，请派人前往查看',
    },
    {
        type: 'primary',
        content: '警告来自xxx区域，发生xxx异常，请派人前往查看',
    },
])
let message = ref({ address: 'sqwe' })
const showNotice = ref(true)

const getAlarm = () => {
    apis.post('/unit/PublicShow/pcIndex', { is_wxc: 1 }).then((res) => {
        if (res.data.warnList.length) {
            message = ref(res.data.warnList[0]) || []
            showNotice.value = true
        }

    })
}
onMounted(() => {
    getAlarm()
})
</script>

<style lang="scss" scoped></style>
